1 00:00:00,350 --> 00:00:01,170 Welcome back. 2 00:00:01,190 --> 00:00:05,990 In this lecture, we're going to take a look at creating our first script and writing down our first 3 00:00:05,990 --> 00:00:09,380 lines of code to create a new script inside of our game. 4 00:00:09,380 --> 00:00:14,900 What we're going to do is we're going to hop into our Explorer menu here and to create a new object 5 00:00:14,900 --> 00:00:20,600 inside of our server script service, we can hit this plus button here or we can right click it and 6 00:00:20,600 --> 00:00:23,120 select the insert object option. 7 00:00:23,120 --> 00:00:28,340 And inside of here we can go ahead and select a script if it automatically shows up for you here. 8 00:00:28,340 --> 00:00:31,640 But if it doesn't, we can also search for a script as well. 9 00:00:31,640 --> 00:00:35,210 And this is the script that we would like to insert into our game. 10 00:00:35,690 --> 00:00:43,460 And a script is simply just a container of Lewis code that gets executed during the runtime of our game. 11 00:00:43,610 --> 00:00:48,770 Inside of our script, you may see that there's already some code inside of here, which is a print 12 00:00:48,770 --> 00:00:55,100 function, printing out some text that would appear inside of our console or our output menu. 13 00:00:55,220 --> 00:01:00,140 Now what we could do inside of this print function is we're going to erase what's inside of here and 14 00:01:00,240 --> 00:01:04,290 we're going to pass our own custom text that we would like to print into the console. 15 00:01:04,290 --> 00:01:10,260 So what we need to do is we would need to create a string data type, which we can create using either 16 00:01:10,260 --> 00:01:12,990 double quotations or a single quotation. 17 00:01:12,990 --> 00:01:17,520 And a string is simply a collection or a string of characters. 18 00:01:17,520 --> 00:01:23,370 So we can go ahead and type within this print function here a message like Hello and hi. 19 00:01:23,610 --> 00:01:27,240 This line that I've created right here is called a statement. 20 00:01:27,240 --> 00:01:31,980 And a statement is simply a line of code that is telling the computer to do a specific task. 21 00:01:31,980 --> 00:01:36,330 If I wanted the computer to change the color of a part to be blue, that would be a statement. 22 00:01:36,330 --> 00:01:39,750 If I had a line of code that killed a player, that would also be a statement. 23 00:01:39,930 --> 00:01:45,810 We can also use this print function multiple different times by first typing out the identifier for 24 00:01:45,810 --> 00:01:50,370 this print function, which would be print, and then to call this print function, I would have to 25 00:01:50,370 --> 00:01:55,980 use two parentheses so I can put in the first one and the second one automatically gets filled out for 26 00:01:55,980 --> 00:01:56,400 me. 27 00:01:56,400 --> 00:02:01,680 And now we can pass even more text inside of this print statement so I can type out another message 28 00:02:01,680 --> 00:02:03,060 like Hello World. 29 00:02:03,650 --> 00:02:08,420 And if you'd like to pass multiple string data types to this print function, you can separate them 30 00:02:08,420 --> 00:02:09,680 by using a comma. 31 00:02:09,680 --> 00:02:17,050 And I'm going to create another string here and say something like, This is the best course on Lulu 32 00:02:17,090 --> 00:02:17,780 scripting. 33 00:02:18,780 --> 00:02:25,080 Now, if you have a very keen eye, you should see that a new tab has appeared inside of studio. 34 00:02:25,110 --> 00:02:30,480 This is the script tab, which contains some extra buttons and features for working on scripts such 35 00:02:30,480 --> 00:02:32,670 as some buttons for when you're working in team. 36 00:02:32,670 --> 00:02:37,450 Create and replacing some text, finding some text in a certain script and stuff like that. 37 00:02:37,470 --> 00:02:41,700 We will be going more in depth about the features of the script tab later in the course, but for now, 38 00:02:41,700 --> 00:02:46,290 in this tab, let's go ahead and run our script by going to this play button and hitting the dropdown 39 00:02:46,290 --> 00:02:48,630 menu here and we're going to hit run. 40 00:02:48,630 --> 00:02:51,030 Or you can also press F8 on your keyboard. 41 00:02:52,620 --> 00:02:58,200 So now that our game has run inside of our output menu, we have the text from our script printed inside 42 00:02:58,200 --> 00:02:59,070 of the console. 43 00:02:59,220 --> 00:03:05,700 The console will also tell you whether or not the server or a client printed this message and it also 44 00:03:05,700 --> 00:03:11,880 tells you the name of the script that printed it and at what line that this text was printed into the 45 00:03:11,880 --> 00:03:12,270 console. 46 00:03:12,270 --> 00:03:16,350 So as you can see in line one of our script we printed out Hello and Hi. 47 00:03:16,380 --> 00:03:19,470 And at line two of our script we printed out Hello World. 48 00:03:19,470 --> 00:03:22,380 And this is the best course on how to use scripting. 49 00:03:23,010 --> 00:03:26,550 We can now go ahead and hit the stop button to end our testing. 50 00:03:26,640 --> 00:03:27,990 And congratulations. 51 00:03:27,990 --> 00:03:32,750 You have successfully created your first script and even executed your first lines of code. 52 00:03:32,760 --> 00:03:36,760 Just know that it's going to get a lot crazier from this point forward. 53 00:03:36,780 --> 00:03:42,330 For now, what I'd like for you to do is to continue messing with this print function, multiple calls 54 00:03:42,330 --> 00:03:47,340 if you'd like, and continue to print any types of text that you'd like into the console. 55 00:03:47,340 --> 00:03:52,350 In the next lecture, I'm going to explain to you the concept of variables and how you can use them 56 00:03:52,350 --> 00:03:53,160 in your scripts. 57 00:03:53,190 --> 00:03:54,060 See you there.